﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace T7task1
{
    public partial class Form1 : Form
    {
        DataTable dt = new DataTable();
        public Form1()
        {
            InitializeComponent();
        }
        //库存降序
        private void button3_Click(object sender, EventArgs e)
        {
            DataView dv = new DataView(dt);
            dv.Sort = "gameStock desc";
            dataGridView1.DataSource = dv;
        }
        //查询单击事件
        private void button1_Click(object sender, EventArgs e)
        {
            DataView dv = new DataView(dt);
            dv.RowFilter = string.Format("gameName like '%{0}%' and gameTxt like '%{1}%'", txtgameName.Text,txtgameStock.Text);
            dataGridView1.DataSource = dv;
        }

        private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
        {
            
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string sql = string.Format("select gameName,gameMoney,gameStock,gameTxt,addTime from Games");
            dt = DBHelper.Select(sql);
            dataGridView1.DataSource = dt;
        }
        //价格升序
        private void btMoneyUp_Click(object sender, EventArgs e)
        {
            DataView dv = new DataView(dt);
            dv.Sort = "gameMoney";
            dataGridView1.DataSource = dv;
        }
    }
}
